package com.dgshanger.sanhxiaofeisc.mvp.model

import com.blankj.utilcode.util.EncryptUtils
import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.mvp.contract.EditPayPasswordContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.RxHttpObserver

/**
 * EditPayPasswordModel
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/4/28 11:40.
 */

class EditPayPasswordModel : EditPayPasswordContract.Model {

    override fun sendCode(phone: String, rxHttpObserver: RxHttpObserver<Any>) {
        AppApi.Api()
                .get_pin(phone, "app_modify_pay_pwd")
                .compose(RxHelper.io_main())
                .subscribe(rxHttpObserver)
    }

    override fun modifyPaypwd(new_pwd: String, confirm_pwd: String, verify_code: String, rxHttpObserver: RxHttpObserver<Any>) {
        AppApi.Api()
                .modify_paypwd(EncryptUtils.encryptMD5ToString(new_pwd).toLowerCase(),
                        EncryptUtils.encryptMD5ToString(confirm_pwd).toLowerCase(),
                        verify_code)
                .compose(RxHelper.io_main())
                .subscribe(rxHttpObserver)
    }
}
